const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');

const app = express();

const port = process.env.PORT || 5000;

//引入user.js
const user = require('./routes/api/users');

//引用body-parse中间件
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());


app.get('/', (req, res) => {
    res.send('hello world');
})

//使用routers
app.use('/api/user', user);

app.listen(port, () => {
    console.log(`Server running on prot ${port}`);
});